﻿using B.Rabbit.DataBase.ErrorCode;
using B.Rabbit.DataBase.Read.Api.Applocation.Command.Rabbit.Breeding;
using B.Rabbit.DataBase.Read.Api.Applocation.Command.Rabbit.Health;
using B.Rabbit.DataBase.Read.Api.DTOs;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.Rabbit.DataBase.Read.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class BreedingController : ControllerBase
    {
        IMediator mediator;

        public BreedingController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 添加养殖信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> AddBreeding(AddBreedingCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 显示养殖列表
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<GetBreedingDTOs>>> GetBreeding([FromQuery]GetBreedingCommand request, CancellationToken cancellationToken)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 保健信息添加
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> AddHealth(AddHealthCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 保健信息列表
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<GetHealthDTOs>>> GetHealth([FromQuery]GetHealthCommand request, CancellationToken cancellationToken)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 删除保健信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> DelHealth(DelHealthCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 更新保健信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> Handle(UpdateHealthCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request);
        }
    }
}
